package org.eenie.appseed.ui.chat

import android.util.Log
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import org.eenie.appseed.R
import org.eenie.appseed.databinding.ImChatTextInBinding
import org.eenie.appseed.ui.chat.models.im.BaseMsg
import org.eenie.appseed.ui.chat.models.im.MsgTypeEnum
import org.eenie.appseed.ui.chat.models.im.TextMsg

class ChatMsgListAdapter : BaseMultiItemQuickAdapter<BaseMsg, BaseViewHolder>(), LoadMoreModule {

    init {
        addItemType(MsgTypeEnum.TEXT_IN.code, R.layout.im_chat_text_in)
        addItemType(MsgTypeEnum.TEXT_OUT.code, R.layout.im_chat_text_out)
    }


    override fun convert(holder: BaseViewHolder, item: BaseMsg) {
        when (item) {
            is TextMsg -> {
                val binding = ImChatTextInBinding.bind(holder.itemView)
                binding.tvMsgContent.text = item.text
            }
        }
    }
}